<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<ul id="errorMsg" style="color:red"></ul>
<form id="regform">
	<input type="hidden"  name="validating" value="true" /> 
	<input type="hidden"  name="bean.department.id" value="${loginUser.department.id}" /> 
	<input type="hidden"  name="bean.role.id" value="008a813b18ab14310118ab154f000001" /> 
	<input type="hidden"  name="bean.enabled" value="false"/> 
	<input type="hidden"  name="bean.authoritys[0].name" value="ROLE_USER" />
	<input type="hidden"  name="bean.primarySecurole.name" value="ROLE_USER" />
	<table style="width: 70%">
		<caption>申请新用户</caption>
		
		<tr>
			<td>用户名</td>
			<td>
			<input name="bean.username" onblur="checkin(this);"/>
			<label id="usermsg" style="color:red"></label>
			</td>		    
		    <td>长度在6-15之间的半角英文字母</td>     
		</tr>
		<tr>
			<td>中文名</td>
			<td>
			<input name="bean.localName" />
			</td>
		    
		    <td></td>     
		</tr>
		<tr>
			<td>密码</td>
			<td><input name="bean.password" type="password" /></td>
			<td></td>
		</tr>
		<tr>
			<td>确认密码</td>
			<td><input name="bean.repassword" type="password"/></td>
		    <td></td>
		</tr>
		
	</table>
</form>
<button class="sexybutton sexysimple sexygreen register"><span class="ok">注册</span></button>
<script type="text/javascript">
$(function(){
   $("button.register").bind("click",function(){
       var data = $("#regform").serialize();
       var url = "admin/preuser/pre-user!add";
       $.post(url,data,function(msg){
    	   $("#errorMsg").empty();
    	   $("#errorMsg").html(msg);     
       });
      
   });         
});
function checkin(user){
   $.getJSON("admin/preuser/pre-user!checkin",{"bean.username":user.value},function(mdata){
         if(mdata['hasin']){
            $("#usermsg").html("用户 "+user.value+" 已存在");     
            user.value='';  
            //user.focus();
         }
   });
}
</script>